package com.cool.controller.smallclasscontroller;

import com.cool.bo.SmallSelectLike;
import com.cool.common.CommonResult;
import com.cool.common.ResponseCode;
import com.cool.po.bigclasspo.BigClassPo;
import com.cool.po.smallclasspo.SmallClassPo;
import com.cool.service.smallclass.SmallClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 商品小类控制层
 * 负责人:曹力引
 */
@RestController
@RequestMapping("smallclass")
public class SmallClassController {
    //注入业务层对象
    @Autowired
    private SmallClassService smallClassService;
    /**
     * 查询所有下拉框
     */
    @RequestMapping("getbigClass")
    CommonResult getbigClass(){
        List<BigClassPo> list = smallClassService.getbigClass();
        return CommonResult.newCommonResult().setCode(ResponseCode.USER_LOGIN_SUCCESS).setMsg("success").setData(list);
    }
    /**
     * 根据下拉框和输入框模糊查询
     */
    @RequestMapping("selectLike")
    CommonResult selectLike(SmallSelectLike smallSelectLike){
        List<Map<String, Object>> list = smallClassService.selectLike(smallSelectLike);
        return CommonResult.newCommonResult().setCode(ResponseCode.USER_LOGIN_SUCCESS).setMsg("success").setData(list);
    }

    /**
     * 查询所有信息
     */
    @RequestMapping("selectAll")
    CommonResult selectAll(){
        List<Map<String, Object>> list = smallClassService.selectAll();
        return CommonResult.newCommonResult().setCode(ResponseCode.USER_LOGIN_SUCCESS).setMsg("success").setData(list);
    }

    /**
     *修改商品小类
     */
    @RequestMapping("updatesmallClass")
    CommonResult updatesmallClass(SmallClassPo smallClassPo){
        smallClassService.updatesmallClass(smallClassPo);
        return CommonResult.newCommonResult().setCode(ResponseCode.USER_LOGIN_SUCCESS).setMsg("success");
    }
}
